/**
 * Printer.java
 *
 * Provider: CoderDream's Studio
 *
 * History
 *	Date(DD/MM/YYYY)    Author          Description
 * ----------------------------------------------------------------------------
 *	Nov 2, 2007		CoderDream		Created
 */
package com.coderdream.chapter21.proxy.sample;

/**
 * <pre>
 * Printer.java
 * </pre>
 * 
 */
public class Printer implements Printable {

	private String name;

	/**
	 * No Param Construtor
	 */
	public Printer() {
		heavyJob("Is Generate Printer Object (" + name + ")");
	}

	/**
	 * 构造函数
	 * 
	 * @param name
	 */
	public Printer(String name) {
		this.name = name;
		heavyJob("Is Generate Printer Object (" + name + ")");
	}

	public String getPrintName() {
		return name;
	}

	public void setPrinterName(String name) {
		this.name = name;
	}

	/**
	 * 打印
	 */
	public void print(String string) {
		System.out.println("=== " + name + " ===");
		System.out.println(string);
	}

	/**
	 * @param msg
	 */
	private void heavyJob(String msg) {
		System.out.print(msg);
		for (int i = 0; i < 5; i++) {
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			System.out.print(".");
		}
		System.out.println("Done .");
	}

}
